package com.aliothservice.catfish.device.data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class TemperatureDocument {
	
	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		
		DateFormat fullFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
		map.put("recordingStart", fullFormatter.format(this.getRecordingStart()));
		if (null != this.getRecordingEnd()) {
			map.put("recordingEnd", fullFormatter.format(this.getRecordingEnd()));
		}
		map.put("temperatureMin", this.getTemperatureMin());
		map.put("temperatureMax", this.getTemperatureMax());
		if (null != this.getTemperatureObjects()) {
			List<Map<String, Object>> objectList = new ArrayList<Map<String, Object>>();
			for (TemperatureObject object : this.getTemperatureObjects()) {
				objectList.add(object.toMap());
			}
			map.put("temperatureObjects", objectList);
		}
		
		return map;
	}
	
	@Id
	private String id;
	
	private String orderId;
	private List<String> viewers;
	private Date recordingStart;
	private Date recordingEnd;
	
	private Integer temperatureMin;
	private Integer temperatureMax;
	
	private List<TemperatureObject> temperatureObjects;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public List<String> getViewers() {
		return viewers;
	}

	public void setViewers(List<String> viewers) {
		this.viewers = viewers;
	}

	public Date getRecordingStart() {
		return recordingStart;
	}

	public void setRecordingStart(Date recordingStart) {
		this.recordingStart = recordingStart;
	}

	public Date getRecordingEnd() {
		return recordingEnd;
	}

	public void setRecordingEnd(Date recordingEnd) {
		this.recordingEnd = recordingEnd;
	}

	public List<TemperatureObject> getTemperatureObjects() {
		return temperatureObjects;
	}

	public void setTemperatureObjects(List<TemperatureObject> temperatureObjects) {
		this.temperatureObjects = temperatureObjects;
	}

	public Integer getTemperatureMin() {
		return temperatureMin;
	}

	public void setTemperatureMin(Integer temperatureMin) {
		this.temperatureMin = temperatureMin;
	}

	public Integer getTemperatureMax() {
		return temperatureMax;
	}

	public void setTemperatureMax(Integer temperatureMax) {
		this.temperatureMax = temperatureMax;
	}

}
